﻿Imports System.Resources

Public Class frmNouvSite

    Private rm As New ResourceManager(GetType(frmNouvSite))
    Private test As String
    Private s As String

    Private intLong As Short
    Private Sub lbPrecision_textChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblPrecision.TextChanged
        s = lblPrecision.Text
    End Sub


    Private Sub actualiserGPS()  
        If (m_isFormGPSOpen = True) And (m_isGpsInterpreteurOpen = True) Then
            If ((Not IsNothing(oCurrentGpsPosition.longitude)) And (Not IsNothing(oCurrentGpsPosition.latitude))) Then
                'Affichage
                lblLatitude.Text = oCurrentGpsPosition.latitude.ToString
                lblLongitude.Text = oCurrentGpsPosition.longitude.ToString
                lblAltitude.Text = oCurrentGpsPosition.altitude.ToString
                lblPrecision.Text = 7 * (CInt(oCurrentGpsPosition.dopH))

            Else
                lblLatitude.Text = Nothing
                lblLongitude.Text = Nothing
                lblAltitude.Text = Nothing
                lblPrecision.Text = Nothing

            End If
        End If

    End Sub


    Private Sub btnAjouterNouvoSite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAjouterNouvoSite.Click
        'Test s'il y a une valeur saisie
        'S'il n'y a rien = Non valide
        If Me.tb_NomSite.Text = "" Then
            MsgBox(DirectCast(My.Resources.Images.alertSiteName, String), MsgBoxStyle.Exclamation, "Pocket eRelevé")
        Else
            Try
                ' Si la liste des sites est vide = Création des entêtes de la liste
                If frmEntryChoixSite.lstViewSite.Items.Count = 0 Then
                    CreateHeadersToListView("id;site;latitude;longitude;altitude;precision", frmEntryChoixSite.lstViewSite)
                End If
                'Ajout du site à la liste en cours
                'pour un nouveau site on met un id vide
                PutDataIntoListView(";" & tb_NomSite.Text & ";" & _
                                    ChangeDecimalSeparator(lblLatitude.Text, SeparateurDecimal, ".") & ";" & _
                                    ChangeDecimalSeparator(lblLongitude.Text, SeparateurDecimal, ".") & ";" & _
                                    lblAltitude.Text & ";" & ChangeDecimalSeparator(lblAltitude.Text, SeparateurDecimal, "."), frmEntryChoixSite.lstViewSite)
                tb_NomSite.Text = " "
                ArrangeListView(frmEntryChoixSite.lstViewSite, 1)
                MsgBox(DirectCast(My.Resources.Images.alertSiteAdd, String))
                Me.Hide()
                frmParamSite.Show()
            Catch ex As Exception
                MsgBox(DirectCast(My.Resources.Images.errorSiteNotAdd, String) & ex.Message, MsgBoxStyle.Critical, "Pocket eRelevé")
            End Try
        End If
    End Sub

    Private Sub btnRetourMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRetourMenu.Click
        ClSIP.HideSIP()
        Me.Hide()
        FormMain.Show()
    End Sub

    Private Sub btnRetour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRetour.Click
        ClSIP.HideSIP()
        Me.Hide()
        frmParamChoixList.Show()
    End Sub

    Private Sub Clavier_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Clavier.Click
        Me.tb_NomSite.Focus()
        ClSIP.ChangeState()
    End Sub

    Private Sub frmNouvSite_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        actualiserGPS()
    End Sub

    Private Sub btnPos_GPS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPos_GPS.Click
        actualiserGPS()
    End Sub

End Class